<br>
<div class="panel panel-default shadowed">
    <div class="panel-heading clearfix">
        <h2 class="panel-title pull-left">Products</h2>
        <div class="pull-right">
            <form class="form">
                <input type="text" class="form-control" ng-model="rsc.searchProducts" placeholder="Search...">
            </form>
        </div>
        <div class="pull-right">
            <button type="button" class="btn btn-primary" ng-click="rsc.editResource(undefined, 'editProducts', rsc.URLS.PRODUCTS_URL, rsc.RESOURCES.PRODUCTS)"><span class="fa fa-plus"></span> Product</button>
        </div>
    </div>
    <div class="panel-body">
        <table class="table table-hover table-mouse-hover">
            <thead>
            <tr>
                <th>Name</th>
                <th>Units</th>
                <th>Cost</th>
                <th>Type</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="product in rsc.products| filter: rsc.searchProducts" ng-click="rsc.editResource(product, 'editProducts', rsc.URLS.PRODUCTS_URL, rsc.RESOURCES.PRODUCTS)">
                <td>{{product.name}}</td>
                <td>{{product.units}}</td>
                <td>{{product.cost}}</td>
                <td>{{product.type}}</td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<script type="text/ng-template" id="editProducts">
    <div class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="editProductsLabel">Edit Product</h4>
                </div>
                <div class="modal-body">
                    <form role="form">
                        <div class="row">
                            <div class="form-group col-md-6">
                                <label for="name">Name</label>
                                <input type="text" ng-model="erc.resource.name" class="form-control" id="name">
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group col-md-4">
                                <label for="type">Type</label>
                                <input type="text" ng-model="erc.resource.type" class="form-control" id="type">
                            </div>
                            <div class="form-group col-md-4">
                                <label for="units">Units</label>
                                <input type="text" ng-model="erc.resource.units" class="form-control" id="units">
                            </div>
                            <div class="form-group col-md-4">
                                <label for="cost">Cost</label>
                                <input type="text" ng-model="erc.resource.cost" class="form-control" id="cost">
                            </div>
                        </div>
                        <div class="pull-right">
                            <button type="button" class="btn btn-primary" ng-click="erc.addProductCrane()"><span class="fa fa-plus"> Crane</span></button>
                        </div>
                        <form role="form">
                            <div class="form-group" ng-repeat="crane in erc.resource.cranes">
                                <div class="row">
                                    <div class="form-group col-md-6">
                                        <label for="crane">Crane</label>
                                        <select class="form-control" ng-model="crane.crane_id" id="crane" ng-options="crane.id as crane.name for crane in erc.cranes">
                                            <option style="display:none" value="">Select a Crane</option>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-2" ng-show="!$first">
                                        <button type="button" style="margin-top: 25px" class="btn btn-danger" ng-click="erc.removeProductCrane($index)"><span class="fa fa-minus"></span></button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-warning" data-dismiss="modal" ng-click="erc.close('none')">
                        <span class="fa fa-close"></span> Cancel
                    </button>
                    <button type="button" class="btn btn-success" data-dismiss="modal" ng-click="erc.close('update')" ng-show="erc.isDeleteAllowed()">
                        <span class="fa fa-check"></span> Update Product
                    </button>
                    <button type="button" class="btn btn-success" data-dismiss="modal" ng-click="erc.close('add')" ng-show="!erc.isDeleteAllowed()">
                        <span class="fa fa-check"></span> Add Product
                    </button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="erc.close('delete')" ng-show="erc.isDeleteAllowed()">
                        <span class="fa fa-trash"></span> Delete Product
                    </button>
                </div>
            </div>
        </div>
    </div>
</script>